#ifndef TRACK_H
#define TRACK_H

#include <vector>
#include <utility>
#include <iterator>
#include <OgreVector3.h>
#include <OgreAxisAlignedBox.h>
#include <boost/foreach.hpp>

#include "TrackTheme.h"
#include "BezierCurve.h"
#include "Trigonometry.h"

#include "TrackNode.h"
#include "TrackVector.h"
#include "DebugTracer.h"

class Jet;
class Player;

enum PlayerPlacement
{
    ONELINE = 0,
    TWOLINES = 1
};
class Track
{
    public:
        Track();
        virtual ~Track();

        void Update(float timedelta);
        void AddTrackNode(Ogre::Vector3 position,
                          Ogre::Vector3 normal,
                          std::string material,
                          Ogre::Real size = 10,
                          bool end = true);

        void SetPlayerList(std::vector<Player*>* player_list,
                           unsigned int player_placement = 1);
        inline std::vector<Jet*>* GetJetList()
        {
            return &m_jetList;
        }
        inline std::vector<TrackVector>& GetVectorList()
        {
            return m_vectorList;
        }
        inline void SetName(Ogre::String name)
        {
            m_name = name;
        }
        inline Ogre::String GetName()
        {
            return m_name;
        }
        inline std::vector<TrackNode>& GetTrackNodeList()
        {
            return m_trackNodeList;
        }
        static const Ogre::Real NODES_PER_METER = 20.0f;
        static const float METERS_PER_NODE = 1/20.0f;
        static const Ogre::Real JET_PLACEMENT_DISTANCE = 1.0f;
        static const int TRACK_ALTITUDE = 1000;
    protected:
        std::vector<Jet*> m_jetList;

        std::vector<Player*>* m_playerList;

        std::vector<TrackNode> m_trackNodeList;

        //the coordinates and the track width vector
        std::vector<TrackVector> m_vectorList;

        void buildTrack();

        Ogre::String m_name;
    private:
};

#endif // TRACK_H
